<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form method="post" onsubmit="return check()">
    <p>
        <label>用户名:</label>
        <input type="text" id="username">
    </p>

    <p>
        <label>密码:</label>
        <input type="password" id="password">
    </p>

    <p>
        <label>邮箱:</label>
        <input type="email" id="email">
    </p>

    <p>
        <input type="submit" value="提交">
    </p>
</form>
    <p style="color: red;" id="error1"></p>
<script src="/static/js/jquery-1.11.0.js"></script>
<script>
    function check() {
        var user = $('#username').val();
        var posd = $('#username').val();
        var email = $('#email').val();

        if (user == '' || posd == ''){
            $('#error1').text('用户名和密码不能为空');
            return false
        }

        var reg = /^[\u4e00-\u9fa5]{3,6}$/;
        if(!reg.test(user)){
            $('#error1').text('用户名必须为3到6位汉字');
            return false
        }

        var reg1 = /^\w{6}$/;
        if(!reg1.test(posd)){
            $('#error1').text('密码必须是6位数字字母下划线');
            return false
        }
        var reg2 = /^[\w\-]+@[a-z0-9A-Z]+(\.[a-zA-Z]{2,3}){1,2}$/;
        if(!reg2.test(email)){
            $('#error1').text('邮箱格式不正确');
            return false
        }
        return true
    }
</script>
</body>
</html>